package com.shun.controller.api

import com.shun.entity.Company
import com.shun.entity.Machine
import com.shun.entity.User
import com.shun.service.CompanyService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

/**
 * Created by rainbow on 2017/9/14.
 *一事专注，便是动人；一生坚守，便是深邃！
 */
@RestController
@RequestMapping("/api/v1/company")
class CompanyController {

    @Autowired
    private lateinit var companyService: CompanyService

    @PostMapping("/create")
    fun create(@SessionAttribute("user") user: User, @RequestBody params: Company) = companyService.create(user, params)


    @GetMapping("/list")
    fun list(@RequestParam params: Map<String, Any>) = companyService.list(params)


    @GetMapping("/query/{searchKey}")
    fun searchKey(@PathVariable searchKey: String) = companyService.getCompany(searchKey)

    @GetMapping("/mapList")
    fun mapList() = companyService.mapList()
}